﻿using System.Collections;
using System.Globalization;
using System.Windows.Data;

namespace CoreModule.Converters
{
    public class StringInterceptingConverter : IValueConverter
    {

        /// <summary>
        /// 
        /// </summary>
        private List<string> _values = new List<string>();
        public IList Values => _values;
        /// <summary>
        /// 
        /// </summary>
        public bool IsNullOrWhiteSpace { get; set; } = true;

        /// <summary>
        /// #81848F
        /// </summary>
        public string EmptyString { get; set; } = string.Empty;
         
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {

            if (IsNullOrWhiteSpace)
            {
                if (string.IsNullOrWhiteSpace(value + ""))
                {
                    return EmptyString;
                }
            }

            if (Values.Contains(value + ""))
            {
                return EmptyString;
            }
            return value;

        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}